<layout name="all@index/layui" />
<style>
    html{  height:100%;}
    body{  height:100%; margin:0;background-color:#ebebeb}
    #head{
        height:150px;
        background-color: #2D93CA;
        text-align: center;

    }
    #head div{
        width:100%;
        max-width:1040px;
        height:100%;
        background-image:url("{$ROOT}/img/logo_big.png");
        background-repeat: no-repeat;
        background-size: 100%;
        background-position: center;
    }
    #login{
        padding-top:50px;
    }
    .layui-form{
        background-color: #fff;
        padding:20px 10px 5px 8px;
        border-radius: 5px;
        box-shadow:2px 2px 1px #888888;
    }
</style>
<div id="head">
    <div class="layui-container">

    </div>
</div>
<div id="login" class="layui-container">
    <form class="layui-form" action="" method="post">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">账户</label>
                <div class="layui-input-inline">
                    <input id="username" type="text" name="username" required  lay-verify="required" placeholder="请输入账户" autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label">密码</label>
                <div class="layui-input-inline">
                    <input type="password" id="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-input-inline">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </div>

    </form>
</div>
<script>
    //Demo
    layui.use(['jquery','form','layer'], function(){
        var form = layui.form
         ,$=layui.$;
        var layer=layui.layer;
        //监听提交
        form.on('submit(formDemo)', function(data){
            var username=$('#username').val();
            var password=$('#password').val();
            password=hex_md5(hex_md5(password)+'{$page.guid}');
            $.post('{$ROOT}/home/login/checklogin',{username:username,pwd:password,code:$('#code').val()},function(result){
                if (result.status==1){
                    location="{$ROOT}/";
                }
                else if(result.status==2){
                    location="{$ROOT}/";
                }
                else if(result.status==4){
                    location="{$ROOT}/admin/?2796";
                }
                else {
                    if(result.status==-1)
                        $('#valid').click();
                    if(result.times>3&&result.status==0){ //如果密码输入错误，刷新页面
                        location=getURLString()+'?t='+Math.random();
                    }
                    layer.msg(result.info);

                }
            },'json');
            return false;
        });

    });
</script>
<script type="text/javascript" src="{$ROOT}/js/md5.js"></script>